﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using KhaoSatSinhVienTotNghiep.Model;

namespace KhaoSatSinhVienTotNghiep.Web.Controllers
{
    public partial class PhieuKhaoSatController : Controller
    {
        //
        // GET: /PhieuKhaoSat/

        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult ThemPhieuKhaoSat(FormCollection frm)
        {
            int idDotKS = 0;
            string name = frm["cauh"].Trim();
            string tenDotKS = frm["TenDotKS"];
            if (DotKhaoSat.AddNew(tenDotKS) == true)
            {
                string[] list = name.Split(' ');
                idDotKS = DotKhaoSat.GetDotKSByName(tenDotKS).MaDotKS;
                ViewBag.ma = idDotKS;
                for (int i = 0; i < list.Count(); i++)
                {
                    PhieuKhaoSat.Add(int.Parse(list[i]), idDotKS);
                }
            }
            var model = CauHoi.GetCauHoiByMaDotKS(idDotKS);
            return View(model);
        }

        public ViewResult PhieuKhaoSats(FormCollection frm)
        {
            string maDotkS = frm["DotKS"];
            List<CauHoi> list = CauHoi.GetCauHoiByMaDotKS(int.Parse(maDotkS));
             ViewBag.myData = int.Parse(maDotkS);
            return View(list);
        }
    
    }
}
